package net.sk.china.city.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import net.sk.china.city.controller.base.BaseController;
import net.sk.china.city.domain.dto.AjaxResult;
import net.sk.china.city.domain.ArRefund;
import net.sk.china.city.service.IArRefundService;
import net.sk.china.city.domain.dto.TableDataInfo;

/**
 * 退款单Controller
 * 
 * @author ruoyi
 * @date 2024-06-06
 */
@RestController
@RequestMapping("/yigoHome/refund")
@Api(tags = "退款单管理")
public class ArRefundController extends BaseController
{
    @Autowired
    private IArRefundService arRefundService;

    /**
     * 查询退款单列表
     */
    @PreAuthorize("hasAnyAuthority('yigoHome:refund:list')")
    @GetMapping("/list")
    @ApiOperation("退款单列表")
    public TableDataInfo list(ArRefund arRefund)
    {
        startPage();
        List<ArRefund> list = arRefundService.selectArRefundList(arRefund);
        return getDataTable(list);
    }

    /**
     * 导出退款单列表
     */
    @PreAuthorize("hasAnyAuthority('yigoHome:refund:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArRefund arRefund)
    {
        List<ArRefund> list = arRefundService.selectArRefundList(arRefund);
//        ExcelUtil<ArRefund> util = new ExcelUtil<ArRefund>(ArRefund.class);
//        util.exportExcel(response, list, "退款单数据");
    }

    /**
     * 获取退款单详细信息
     */
    @ApiOperation("退款单详情")
    @PreAuthorize("hasAnyAuthority('yigoHome:refund:query')")
    @GetMapping(value = "/{pkId}")
    public AjaxResult getInfo(@PathVariable("pkId") Long pkId)
    {
        return success(arRefundService.selectArRefundByPkId(pkId));
    }

    /**
     * 新增退款单
     */
    @PreAuthorize("hasAnyAuthority('yigoHome:refund:add')")
    @PostMapping
    public AjaxResult add(@RequestBody ArRefund arRefund)
    {
        return toAjax(arRefundService.insertArRefund(arRefund));
    }

    /**
     * 修改退款单
     */
    @ApiOperation("退款单修改")
    @PreAuthorize("hasAnyAuthority('yigoHome:refund:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody ArRefund arRefund)
    {
        return toAjax(arRefundService.updateArRefund(arRefund));
    }

    /**
     * 删除退款单
     */
    @ApiOperation("退款单删除")
    @PreAuthorize("hasAnyAuthority('yigoHome:refund:remove')")
	@DeleteMapping("/{pkIds}")
    public AjaxResult remove(@PathVariable Long[] pkIds)
    {
        return toAjax(arRefundService.deleteArRefundByPkIds(pkIds));
    }
}
